<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的</title>
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <link rel="stylesheet" type="text/css" href="css/aui.css"/>
    <script src="js/art-template.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <script src="js/wxrem.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/md5.js" type="text/javascript" charset="utf-8"></script>
    <!--<script src="//s.url.cn/qqun/qun/qqweb/m/qun/confession/js/vconsole.min.js"></script>-->

    <script type="text/javascript">
        document.writeln("<script type=\"text/javascript\" src=\"js/common.js?" + Math.random() + "\"></scr" + "ipt>");
    </script>
</head>
<style>
    body {

    }

    .my_box {
        height: 100%;

    }

    #footer {
        background-color: #f2f2f2;
        height: 4.9rem;
    }

    #footer ul li {
        background: url() no-repeat center 5px;
        text-align: center;
        color: #666666;
    }

    #footer ul li.active {
        color: #282828;
    }

    #footer ul li:nth-child(1) {
        background-image: url(icon/home.png);
    }

    #footer ul li:nth-child(2).active {
        background-image: url(icon/me_hover.png);
    }

    .my_top {
        height: 5.1rem;
        padding: 0 1.5rem;
        margin-bottom: 1.2rem;
        border-bottom: 1px solid #ebebeb;
    }

    .my_top div:nth-child(1) {
        width: 80%;
        float: left;
    }

    .my_top div:nth-child(2) {
        width: 20%;
        float: left;
    }

    .my_top img {
        height: 3.8rem;
        width: 3.8rem;
        margin-right: 1.5rem;
        margin-top: .5rem;
        border-radius: 50%;
    }

    .mod {
        text-align: right;
        line-height: 5.1rem;
        font-size: 1.4rem;
    }

    .my_msg p {
        line-height: 5.1rem;
        font-size: 1.5rem;
        color: #101010;
    }

    .my_msg {
        display: flex;
    }

    .my_li {
        width: calc(100% - 3rem);
        margin: 0 auto;
        border-radius: 4px;
        border: 1px solid #ebebeb;
        box-shadow: 0px 5px 20px #ededed;
        background: white;
    }

    .my_li > div {
        width: 100%;
        padding: 0 1.5rem;
        font-size: 1.5rem;
        height: 5rem;
    }

    .my_li > div > div {
        width: 50%;
        float: left;
        line-height: 5rem;
        color: #333;

    }

    .my_top {
        background: white;
    }

    .my_li > div:nth-child(2) {
        border-top: 1px solid #ebebeb;
        width: calc(100% - 3rem);
        height: 1px !important;
        margin: 0 auto;
    }

    .my_li > div > div:nth-child(2) {
        text-align: right;
    }

    .my_withdraw {
        width: calc(100% - 3rem);
        margin: 2rem auto;
        border-radius: 4px;
        border: 1px solid #ebebeb;
        height: 21.3rem;
        padding: 0 1.5rem;
        box-shadow: 0px 5px 20px #ededed;
        background: white;

    }

    .my_withdraw > div:nth-child(1) {
        height: 6rem;
        line-height: 6rem;
        font-size: 1.3rem;
    }

    .my_withdraw_center {
        height: 5rem;
        display: flex;
        line-height: 5rem;
    }

    .my_withdraw_center h2 {
        flex: 1;
        -webkit-flex: 1;
        font-size: 4rem;
        color: #202020;
        font-weight: bold;
        margin-left: -0.7rem;
    }

    .my_withdraw_center p {
        width: 6.35rem;
        height: 2.85rem;
        line-height: 2.85rem;
        background: #ffda43;
        border-radius: 8rem;
        text-align: center;
        margin-top: 1.075rem;
        font-size: 1.5rem;
        color: #444;

    }

    .my_withdraw > div:nth-child(3) {
        height: 8.2rem;
    }

    .my_withdraw_msg {
        display: flex;
        padding: 2rem 0;
    }

    .my_withdraw_msg div {
        flex: 1;
        -webkit-flex: 1;
        /*border-right: 1px solid #ebebeb;*/
        text-align: center;
    }

    .my_withdraw_msg div:last-child {
        border-right: 0;
        /*text-align: right;*/
    }

    .my_withdraw_msg div:first-child {
        /*text-align: left;*/
    }

    .my_withdraw_msg div p {
        color: #666666;
        font-size: 1.3rem;
    }

    .my_withdraw_msg div h5 {
        margin-bottom: .5rem;
        font-size: 1.5rem;
        color: #241e20;
        font-weight: 500;
    }

    .my_bottom {
        width: calc(100% - 3rem);
        margin: 0rem auto 8rem;
        border-radius: 4px;
        border: 1px solid #ebebeb;
        padding: 2.5rem 1.5rem 1.7rem;
        box-shadow: 0px 5px 20px #ededed;
        background: white;
    }

    .my_bottom > div:nth-child(1) {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }

    .my_bottom_title, .my_bottom_detail {
        display: flex;
        height: 3.875rem;
    }

    .my_bottom_detail {
        border-top: 1px solid #ededed;
    }

    .my_bottom_title div, .my_bottom_detail div {
        flex: 1;
        -webkit-flex: 1;
        height: 3.875rem;
        line-height: 3.875rem;
        font-size: 1.4rem;
    }

    .my_li img {
        float: right;
        height: 1.5rem;
        width: 1.5rem;
        margin-top: 1.9rem;
    }

    .mod img {
        float: right;
        height: 1.5rem;
        width: 1.5rem;
        margin-top: 1.8rem;
    }

    .solid_hr {
        border-top: 1px solid #ebebeb;
        width: 100%;
        height: 1px !important;
        margin: 1.5rem auto 0;
    }

    .my_withdraw_msg div h5 {
        text-align: center !important;
    }

    .my_bottom_msg div {
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        text-align: center;
    }

    .my_bottom_title div:first-child, .my_bottom_detail div:first-child {
        text-align: left;
    }

    .my_bottom_title div:last-child, .my_bottom_detail div:last-child {
        /*text-align: right;*/
    }

    .my_li_code span {
        font-size: 1.2rem;
        color: #ee1800;
    }

    .my_bottom_detail div span {
        width: 88%;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        text-align: center;
        display: block;
    }
</style>
<body>
<div class="my_box">
    <div style="background:#f5f5f5;">
        <div class="my_top">
            <div class="my_msg">
                <img src="" alt="">
                <p>名字</p>
            </div>
            <div class="mod">
                <img src="icon/jiantou.png" alt="">
            </div>
        </div>


        <div class="my_li">
            <div class="my_li_url">
                <div>推广链接</div>
                <div><img src="icon/jiantou.png" alt=""></div>
            </div>
            <div></div>
            <div class="my_li_code">
                <div class="">每日听书推送</div>
                <div><span></span><img src="icon/jiantou.png" alt=""></div>
            </div>
        </div>


        <div class="my_withdraw">
            <div>可提现金额（元）</div>
            <div class="my_withdraw_center">
                <h2>￥0.00</h2>
                <!--<p>提现</p>-->
            </div>
            <p class="solid_hr"></p>
            <div class="my_withdraw_msg">

            </div>
        </div>
        <div style="padding-bottom: 0.5rem;">

            <div class="my_bottom">
                <div>
                    今日成交
                </div>
                <div class="my_bottom_msg">
                    <div class="my_bottom_title">
                        <div>用户</div>
                        <div>购买产品</div>
                        <div>支付金额</div>
                        <div>购买时间</div>
                    </div>
                    <div class="my_detail" style="">

                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<div id="footer" class="border-t" style="position: fixed;bottom: 0;left: 0;z-index: 99;width: 100%;height: 4.9rem;">
    <ul class="flex-wrap" style="height: 4.9rem;">
        <li id="center" tapmode="hover" class="flex-con"
            style="height: 4.9rem;background-size: 2rem 2rem;line-height: 7.8rem; font-size: 1.3rem;">首页展示
        </li>
        <li tapmode="hover" class="flex-con active"
            style="height: 4.9rem;background-size: 2rem 2rem;line-height: 7.8rem; font-size: 1.3rem;">分销管理
        </li>
    </ul>
</div>
</body>
<script type="text/javascript">
    //获取商户信息
    var signs = hex_md5(objKeySort({token: token, timestamp: date}))
    $.ajax({
        type: "get",
        url: hostUrl + 'merchant/update/info/get',
        data: {
            token: token,
            timestamp: date,
            sign: signs,
        },
        async: true,
        success: function (data) {
            $('.my_msg p').text(data.data.nickname)//商户名称
            $('.my_msg img').attr('src', data.data.headImgUrl)//商户头像
        }
    });


    //分销商订单查询
    var sign = hex_md5(objKeySort({token: token, timestamp: date}))
    $.ajax({
        type: "get",
        // url:hostUrl + 'merchant/orders/'+ token +'/'+ sign +'/'+ date  ,
        url: hostUrl + 'merchant/orders',
        data: {
            token: token,
            timestamp: date,
            sign: sign
        },
        async: true,
        success: function (res) {
            if (res.status == 0) {

                var data = res.data.orderList
                if (data.length == 0) {
                    $('.my_detail').append('<div style="color: #999; padding-top: 2rem ;">您还没有订单呦~</div>')
                } else {
                    $.each(data, function (i, item) {
                        $('.my_detail').append('<div class="my_bottom_detail">' +
                            '                            <div> <span>' + item.userName + '</span></div>' +
                            '                            <div><span>' + item.productName + '</span></div>' +
                            '                            <div style="color: #ff952b">' + item.productPrice + '</div>' +
                            '                            <div style="color: #999">' + item.payTime + '</div>' +
                            '                        </div>')
                    })
                }

                var obj = res.data.orderStatistics
                $('.my_withdraw_msg').append(' <div><h5>' + obj.todayIncome + '</h5><p>今日收入</p></div>' +
                    '    <div><h5>' + obj.todayOrder + '</h5><p>今日订单</p></div>' +
                    '    <div><h5>' + obj.totalIncome + '</h5><p>总收入</p></div>' +
                    '    <div><h5>' + obj.totalOrder + '</h5><p>总订单</p></div>')
            }

        }
    });
    //查询用户余额
    $.ajax({
        type: "get",
        url: hostUrl + 'merchant/balance',
        async: true,
        data: {
            token: token,
            timestamp: date,
            sign: sign
        },
        success: function (res) {
            if (res.status == 0) {
                $('.my_withdraw_center h2').text('￥' + res.data)
            }
        }
    });

    //查询用户是否接入服务号
    // var sign = hex_md5(objKeySort({token: token, timestamp: date}))
    $.ajax({
        type: "get",
        url: hostUrl + 'merchant/check_auth_url/' + token + '/' + sign + '/' + date,
        async: true,
        success: function (data) {
            if (data.status == 1) {
                $('.my_li_code span').text('活跃用户，提升付费转化')
            } else {
                $('.my_li_code span').text('已接入服务号')
            }
        }
    });

    //修改店铺信息
    $(".mod").click(function () {
        location.href = "shopMod.html";
    })

    //提现页面跳转
    $(".my_withdraw_center p").click(function () {
        location.href = "withdraw.html";
    })
    //跳转分销商首页
    $("#center").click(function () {
        location.href = "index_fxs.html?my=1";
    })
    // 跳转分享页面
    $(".my_li_url").click(function () {

        location.href = "referralLinks.html";

    })
    //跳转接入服务号页面
    $(".my_li_code").click(function () {
        var obj = {token: token, timestamp: date}
        var sign = hex_md5(objKeySort(obj))
        $.ajax({
            type: "get",
            url: hostUrl + 'merchant/check_auth_url/' + token + '/' + sign + '/' + date,
            async: true,
            success: function (data) {
                if (data.status == 1) {
                    location.href = "joinUp.html";
                    $('.my_li_code span').text('活跃用户，提升付费转化')
                } else {
                    $('.my_li_code span').text('已接入服务好')

                    $.ajax({
                        type: "get",
                        url: hostUrl + "merchant/template/get",
                        data: {token: token, timestamp: date, sign: sign},
                        async: true,
                        success: function (data) {
                            var obj = data.data
                            var arr = []
                            for (var i = 0; i < obj.length; i++) {//循环判断拿到消息对应的模板
                                if (obj[i].title == '会员到期通知' || obj[i].title == '学习计划提醒') {
                                    if (obj[i].deputyIndustry == '培训' && obj[i].primaryIndustry == '教育')
                                        arr.push(data.data[i])
                                }
                            }
                            if (arr.length < 2) { //判断是否有对应的消息模板
                                location.href = "service.html"
                            } else {
                                location.href = "joinUp.html";
                            }
                        }
                    });

                }
            }
        });

    })


    //禁止分享
    function onBridgeReady() {
        WeixinJSBridge.call('hideOptionMenu');
    }

    if (typeof WeixinJSBridge == "undefined") {
        if (document.addEventListener) {
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        } else if (document.attachEvent) {
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    } else {
        onBridgeReady();
    }
</script>
</html>